package com.dtkavin.sparkstreaming

import org.apache.spark.SparkConf
import org.apache.spark.streaming.kafka.KafkaUtils
import org.apache.spark.streaming.{Milliseconds, StreamingContext}

/**
  * Created by IntelliJ IDEA.
  * Programmer : John Zn
  * Date : 2016/4/20 0020
  * Time : 23:10
  * Discribtion : 从flume到kaffka再到 streaming的数据采集流程
  */
class Flume_kaffka_Streaming {

}

object Flume_kaffka_Streaming{
  def main(args: Array[String]) {
//    Zookeeper quorum (hostname:port,hostname:port,..)
//    The group id for this consumer
//    Map of (topic_name -> numPartitions) to consume. Each partition is consumed
//      *                  in its own thread
    val Array(zkQuorum, group, topics, numThreads) = args
    val conf = new SparkConf().setAppName("Flume_kaffka_Streaming").setMaster("local[3]")
    val ssc = new StreamingContext(conf, Milliseconds(5000))
//    ssc.checkpoint("d:/data/checkpoint")
    val topicMap = topics.split(",").map((_, numThreads.toInt)).toMap
    val data =  KafkaUtils.createStream(ssc,zkQuorum,group,topicMap)
    data.print()

    ssc.start()
    ssc.awaitTermination()
  }
}
